#include <iostream>
using namespace std;

int removeDuplicates(int A[], int n) {
    // Start typing your C/C++ solution below
    // DO NOT write int main() function
    if(n<2){
        return n;
    }

    int readi = 1;
    int writei = 1;
    int count = 1;
    for(readi = 1; readi<n; ++readi){
        // different
        if(A[readi] != A[readi-1]){
            A[writei] = A[readi];
            ++writei;
            count = 1;
        }
        else if(count == 1){
        // same but only once
            A[writei] = A[readi];
            ++writei;
            ++count;
        }
    }

    return writei;
}


int main()
{

}